import { NextRequest } from "next/server";
import { headers, cookies } from "next/headers";
import { redirect } from "next/navigation"

export async function GET(req: NextRequest) {
  console.log(req.headers)
  console.log('content-type@request', req.headers.get('content-type'))
  console.log('cookie location', req.cookies.get('location'))

  console.log('content-type@function', headers().get(('content-type')))
  console.log('cookie location', cookies().get('location'))
  cookies().set("location", "root")

  if (cookies().get('location')?.value === 'root') {
    redirect('/')
  }
  else return Response.json({data: '123'}, {
    headers: {
      "Customized": "x",
      // "Set-Cookie": "location=Shanghai",
    }
  })
}
